package com.cj.simple;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

import com.cj.library.widget.recyclerview.adapter.BaseRecyclerAdapter;
import com.cj.library.widget.recyclerview.adapter.CJDividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by peter on 2016/9/8.
 */
public class RecyclerActivity extends Activity {

    private RecyclerView recyclerView;
    private List<String> mDatas;
    private RecyclerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler);

        mDatas = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            mDatas.add("position:" + i);
        }

        recyclerView = (RecyclerView) findViewById(R.id.revyvler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
//        recyclerView.setLayoutManager(new GridLayoutManager(this,3));

        adapter = new RecyclerAdapter(recyclerView, mDatas, R.layout.item_recycle);
        adapter.setOnItemClickListener(new BaseRecyclerAdapter.OnItetmClickListener<String>() {
            @Override
            public void onItemClick(View view, String item, int position) {
                Toast.makeText(RecyclerActivity.this,item,Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(RecyclerActivity.this,TimerActivity.class);
                startActivity(intent);
            }
        });
        recyclerView.addItemDecoration(new CJDividerItemDecoration());
//        recyclerView.setItemAnimator(new SlideInOutBottomItemAnimator(recyclerView));
        recyclerView.setAdapter(adapter);
    }
}
